import React            from 'react';

import Config           from '../../config';
import loadBMap         from '../../utils/BMap';
import './shop.scss';

export default class extends React.Component {

    componentWillMount(){
        document.title = '门店地址';
    }

    componentDidMount(){
        var {key, latitude, longitude} = Config.INFO.point;
        loadBMap().then(BMap => {
            var map = new BMap.Map(this.refs.map);
            map.centerAndZoom(new BMap.Point(longitude, latitude), 11);
            new BMap.LocalSearch(map, {renderOptions:{map}, pageCapacity: 1}).search(key);
        });
    }

    render(){
        var {name, point, grade, phone, address, description} = Config.INFO;
        return (
            <div className="shop">
                <div ref="map" className="s-map" />
                <div className="s-body">
                    <div className="sb-title">{name}</div>
                    <div>评分：{grade}</div>
                    <div>电话：{phone}</div>
                    <div>地址：{address}</div>
                    <div>{description}</div>
                </div>
            </div>
        );
    }

}
